<?php
// ---------------------------------
// model
// ---------------------------------
function validate_image($image)
{
//	// 上传的文件类型必须是图片
//	if ($image['type'] != )
//	{
//		return false;
//	}
//
//	// 上传文件大小必须在1M以下
//	if ()
//	{
//	}

	if ($image["error"] != UPLOAD_ERR_OK)
	{
		return false;
	}
	return true;
}

function upload_image($image, $uploaddir)
{
	$upload_file = array();

	$upload_file_path = $uploaddir . basename($image['name']);
	if (!move_uploaded_file($image['tmp_name'], $upload_file_path))
	{
		return NULL;
	}

	//TODO resize image
	$upload_file = convert_image(basename($image['name']));
	return $upload_file;
}

function convert_image($orginal_image)
{
	$image["small_image"] = $orginal_image;
	$image["big_image"] = $orginal_image;
	return $image;
}
?>
